<?php

namespace App\Controllers;

use JsonLowCode\Menu;

class User
{
    public function info(){
        return response()->result([
            "id"=> 1,
            "password"=> '123456',
            "realName"=> 'Admin',
            "roles"=> ['admin'],
            "username"=> 'admin',
            "accessToken"=> uniqid()
        ]);
    }

    public function index(){

    }

    public function getUserRoutes(){
        $routes = [];
        $routes[] = Menu::layout("home")->icon('mdi:monitor-dashboard')->i18nKey('route.home')->order(1);
//        $routes[] = Menu::layout("user-center","用户中心")->hideInMenu()->order(1);

        $document = Menu::base("document","文档页")->icon('mdi:file-document-multiple-outline')->order(2);
//        https://www.naiveui.com/zh-CN/os-theme/docs/introduction
        $document->children([
            Menu::iframe("document_antd","Ant Design Vue文档")->url("https://antdv.com/components/overview-cn")->icon("logos:ant-design")->order(7),
            Menu::iframe("document_naive","Naive UI文档")->url("https://www.naiveui.com/zh-CN/os-theme")->icon("logos:naiveui")->order(6),
            Menu::iframe("document_project","项目文档")->url("https://docs.soybeanjs.cn/zh")->localIcon("logo")->order(1),
            Menu::iframe("document_project-link","项目文档(外链)")->href("https://docs.soybeanjs.cn/zh")->localIcon("logo")->order(2),
            Menu::iframe("document_unocss","UnoCSS文档")->url("https://unocss.dev/")->icon("logos:unocss")->order(5),
            Menu::iframe("document_vite","Vite文档")->url("https://cn.vitejs.dev/")->icon("logos:vitejs")->order(4),
            Menu::iframe("document_vue","Vue文档")->url("https://cn.vuejs.org/")->icon("logos:vue")->order(3),
        ]);
        $routes[] = $document;

//        $function = Menu::base("function","系统功能")->icon('icon-park-outline:all-application')->order(3);
//        $function->children([
//            Menu::view("function_tab","标签页")->icon("ic:round-tab")->order(1),
//            Menu::view("function_multi-tab","更多标签")->icon("ic:round-tab")
//                ->hideInMenu()->multiTab()->activeMenu("function_tab"),
//            Menu::menu("function_hide-child","隐藏子菜单")->redirect('/function/hide-child/one')
//                ->icon("material-symbols:filter-list-off")->order(2)->children([
//                    Menu::view("function_hide-child_one","子菜单")->hideInMenu()->activeMenu("function_hide-child"),
//                    Menu::view("function_hide-child_two","子菜单二")->hideInMenu()->activeMenu("function_hide-child"),
//                    Menu::view("function_hide-child_three","子菜单三")->hideInMenu()->activeMenu("function_hide-child"),
//                ]),
//            Menu::view("function_request","请求页")->icon("carbon:network-overlay")->order(3),
//            Menu::view("function_super-page","超级管理员可见")->icon("ic:round-supervisor-account")->order(5),
//            Menu::view("function_toggle-auth","切换权限")->icon("ic:round-construction")->order(4),
//        ]);
//        $routes[] = $function;

        $exception = Menu::base("exception","异常页")->icon("ant-design:exception-outlined")->order(7);
        $exception->children([
            Menu::view("exception_403","403")->icon("ic:baseline-block")->component("403"),
            Menu::view("exception_404","404")->icon("ic:baseline-web-asset-off")->component("404"),
            Menu::view("exception_500","500")->icon("ic:baseline-wifi-off")->component("500"),
        ]);
        $routes[] = $exception;
//
//        $manage = Menu::base("manage","系统管理")->icon("carbon:cloud-service-management")->order(9);
//        $manage->children([
//            Menu::view("manage_menu","菜单管理")->icon("material-symbols:route")->order(3)->keepAlive(),
//            Menu::view("manage_role","角色管理")->icon("carbon:user-role")->order(2),
//            Menu::view("manage_user","用户管理")->icon("ic:round-manage-accounts")->order(1),
//            Menu::view("manage_user-detail","用户详情")->path("/manage/user-detail/:id")->hideInMenu()->activeMenu("manage_user")->props(),
//        ]);
//        $routes[] = $manage;

//        $multiMenu = Menu::base("multi-menu","多级菜单")->order(8)->children([
//            Menu::menu("multi-menu_first","菜单一")->order(1)->children([
//                Menu::view("multi-menu_first_child","菜单一-1")
//            ]),
//            Menu::menu("multi-menu_second","菜单二")->order(2)->children([
//                Menu::menu("multi-menu_second_child","菜单二-1")->children([
//                    Menu::view("multi-menu_second_child_home","菜单二-2")
//                ]),
//            ]),
//        ]);
//        $routes[] = $multiMenu;

//        $routes[] = Menu::layout("about","关于")->icon("fluent:book-information-24-regular")->order(10);
        $routes[] = Menu::render("base","UI基础")->order(11);
        $routes[] = Menu::render("base1","控制台1")->order(11);
        $routes[] = Menu::render("base2","控制台2")->order(11);
        $data = [
            "home"=>"home",
            "routes"=>$routes
        ];
        echo json_encode(["result"=>['data'=>$data,'error'=>''],"status"=>1,"msg"=>"ok"]);
//        return response()->result(["data"=>$data,'error'=>'']);
    }
}